#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int f = 0, ans = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
constexpr int N = 5e5 + 5, M = 19;
int n, k, now;
int id[M], mp[M][M];
vector<int> g[N];
inline bool is_chain()
{
    int c1 = 0, c2 = 0;
    for (int i = 1; i <= n; ++i)
        c1 += g[i].size() == 1, c2 += g[i].size() == 2;
    return c1 == 2 && c2 == n - 2;
}
bool dfs(int u, int fa, int d, int s)
{
    if (mp[now][u])
        return mp[now][u];
    if (d == k)
        return mp[now][u] = s == 1;
    for (int &v : g[u])
        if (v != fa && !dfs(v, u, d + 1, s + id[v]))
            return mp[now][u] = 0;
    return mp[now][u] = 1;
}
signed main()
{
    freopen("life.in", "r", stdin);
    freopen("life.out", "w", stdout);
    n = read(), k = read();
    for (int i = 1; i < n; ++i)
    {
        int u = read(), v = read();
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    if (is_chain())
    {
        puts("YES");
        write(k), putchar('\n');
        return 0;
    }
    int ans = 0;
    for (int i = 1; i < 1 << n; ++i)
    {
        memset(mp, 0, sizeof mp);
        for (int j = 1; j <= n; ++j)
            id[j] = i >> j - 1 & 1;
        int fl = 1;
        for (now = 1; now <= n && fl; ++now)
            fl &= dfs(now, 0, 1, id[now]);
        ans += fl;
    }
    puts(ans ? "YES" : "NO");
    write(ans), putchar('\n');
    return 0;
}